<?php

namespace Data;

class Account extends Base {

    public function getByAccount($account) {
        $info = $this->where(array('Account' => $account))->findOne();
        return $info;
    }

    /**
     * 根据Id获取账户信息
     *
     * @param $id
     *
     * @return array
     */
    public function getInfoById($id) {
        $info = $this->where(array('id' => $id))->findOne();
        return $info;
    }

    public function updatePassword($accountId, $newPassword) {
        $condition = array('Id' => (int) $accountId);
        $data = array('Password' => $newPassword);
        return $this->where($condition)->update($data);
    }

    public function add($account, $password, $groupId) {
        $data = array(
            'Account' => $account,
            'Password' => $password,
            'GroupId' => $groupId,
        );
        $this->insert($data);
    }

}